package gongjiao.yunxi.com.utilsprivacypolicy;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.Log;
import android.widget.Toast;

import com.utils.lib.base.UBaseSplashActivity;
import com.utils.lib.http.UConstant;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnNeverAskAgain;
import permissions.dispatcher.OnPermissionDenied;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

@RuntimePermissions
public class SplashActivity extends UBaseSplashActivity {

    public void initUContent() {
        UConstant.initConstant("ali", Constant.APPKEY, Constant.sign,
                Constant.POSITION_ID,  Constant.APP_ID, "http://api.sjsj.cn/index.php");
    }

    @Override
    public void initPermission() {
        SplashActivityPermissionsDispatcher.onNeed1WithPermissionCheck(this);
    }

    @Override
    protected void initData() { }

    @Override
    public void starMain(int i) {
        Log.d("--111-- error:",""+i);
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
    }

    @SuppressLint("NeedOnRequestPermissionsResult")
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        if (isTrue) {
            SplashActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
        }
    }

    @NeedsPermission(value = {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onNeed1() {
        initADType(1);
    }

    @SuppressLint("NoCorrespondingNeedsPermission")
    @OnShowRationale({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onShowRationale1(final PermissionRequest request) {
        request.proceed();
    }

    @OnNeverAskAgain({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onNeverAsk1() {
        showDialog();
        isTrue = false;
    }

    @OnPermissionDenied({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onPermission1() {
        SplashActivityPermissionsDispatcher.onNeed1WithPermissionCheck(SplashActivity.this);
    }
    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public String getQYID() {
        return "";
//        return "7d9d41bee2112e2f4c3e80f20989091b";
    }

    @Override
    protected int getImgLogo() {
        return R.mipmap.ic_gou;
    }


    @Override
    public double getImgLogoScale(int height) {
        return height/5;
    }
    @Override
    protected int getImg() {
        return R.mipmap.ic_gou;
    }

}
